# include<stdio.h>
long fun(int x,int y,long *p)
{
	int i;
	long t=1;
	for(i=1;i<=y;i++)
	{
		t=t*x;
	}
	*p=t;
	t=t%1000;
	return t;
}
void main()
{
	long t,r;
	int x,y;
	scanf("%ld%ld",&x,&y);
	t=fun(x,y,&r);
	printf("\nx=%d,y=%d,r=%ld,last=%ld\n",x,y,r,t);
}